package view.panel;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class WordSentencePanel extends JPanel
{
	private static final long serialVersionUID = -8121377766133260653L;

	private JTextField word;
	private JTextArea sentence;

	public WordSentencePanel()
	{
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		
		this.setPreferredSize(new Dimension(300, 80));
		
		word = new JTextField();
		word.setHorizontalAlignment(SwingConstants.CENTER);
		word.setEditable(false);
		word.setBackground(null);
		word.setBorder(null);
		word.setAlignmentX(Component.CENTER_ALIGNMENT);
		word.setFont(new Font("Serif", Font.BOLD, 30));

		sentence = new JTextArea();
		sentence.setWrapStyleWord(true);
		sentence.setLineWrap(true);
		sentence.setRows(2);
		sentence.setEditable(false);
		sentence.setBackground(word.getBackground());
		sentence.setOpaque(true);
		sentence.setAlignmentX(Component.CENTER_ALIGNMENT);

		this.add(word);
		this.add(sentence);
	}

	public void reset()
	{
		this.update("", "");
	}

	public void update(String word, String sentence)
	{
		this.word.setText(word);
		this.sentence.setText(sentence);
	}
}